package com.cloud.cloudBatis.session.impl;

import com.cloud.cloudBatis.config.Configuration;
import com.cloud.cloudBatis.session.Excutor;
import com.cloud.cloudBatis.session.SqlSession;
import com.cloud.cloudBatis.session.SqlSessionFactory;

/**
 * 保存组装好的Configuration配置信息
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {
    private Configuration configuration;
    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public Configuration getConfiguration() {
        return configuration;
    }

    @Override
    public SqlSession getSqlSession() {
        Excutor excutor = new DefaultExcutor(configuration.getJdbcProperties());
        return new DefaultSqlSession(excutor, configuration);
    }


}
